package com.example.backendmanage.common.exception;

import com.example.backendmanage.common.AjaxResult;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class MyExceptionHandler {
    /*
     * 如果抛出 ServiceException则调用该方法
     *
     */
    @org.springframework.web.bind.annotation.ExceptionHandler(ServiceException.class)
    @ResponseBody
    public AjaxResult handle(ServiceException se){
        return AjaxResult.fail(Integer.valueOf(se.getCode()),se.getMessage());
    }
}
